package concurrent;

/**
 * @program: study2025
 * @description:
 * @author: liuChangFu
 * @data: 2025-02-10 15:45
 **/
public class StopThread implements Runnable{
    @Override
    public void run() {
        int count = 0;
        while(!Thread.currentThread().isInterrupted() && count < 100){
            System.out.println("count = "+ count ++);
            try {
                System.out.println(Thread.currentThread().isInterrupted());
                Thread.sleep(100000);
            } catch (InterruptedException e) {
                System.out.println(Thread.currentThread().isInterrupted());
                Thread.currentThread().interrupt();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new StopThread());
        thread.start();
        thread.notify();
        Thread.sleep(5);
        thread.interrupt();
    }
}
